package com.zzyl.job;

import com.zzyl.service.DeviceDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
@Slf4j
public class DeleteDeviceDataJob {

    @Autowired
    private DeviceDataService deviceDataService;

    /**
     * 一个月前的数据删除
     * 每天凌晨0点执行一次
     */
    @Scheduled(cron = "0 0 * * * ? ")
    public void deleteDeviceData() {
        deviceDataService.deleteDeviceData(LocalDateTime.now().withHour(0).minusMonths(1));
    }
}
